
package com.epam.android.training.day3.task2;

import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.widget.Toast;

/**
 * Application activity which monitors changes of device orientation.
 * 
 * @author Anton Novikau
 */
public class DeviceConfigurationMonitor extends Activity {

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    /**
     * Called by the system when the device configuration changes while the
     * activity is running.
     */
    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);

        showToastMessage(R.string.message);
    }

    private void showToastMessage(int messageResource) {
        Toast.makeText(getApplicationContext(), messageResource, Toast.LENGTH_SHORT).show();
    }
}
